<?php

/**
 * Copyright 2008 William J. Szerdy Jr.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * @author Bill Szerdy <bszerdy@gmail.com>
 *
 * 12.05.2008 - bszerdy : Created.
 *
 */

class SingleBlind implements PokerBlind{
	private $level;
	private $small_blind;
	private $big_blind;
	private $ante;
	private $time;

	/**
	 * Full constructor
	 */
	public function __construct ($in_level, $in_small, $in_big, $in_ante, $in_time) {
		$this->level		= $in_level;
		$this->small_blind	= $in_small;
		$this->big_blind	= $in_big;
		$this->ante			= $in_ante;
		$this->time			= $in_time;
	}

    public function __get($key) {
        if (isset($this->$key)) {
            return $this->$key;
        } else {
            throw new Exception("Property ‘{$key}’ does not exist");
        }
    }

    public function __set($key, $value) {
        $this->$key = $value;
    }

    public function __toString() {
        return "Level: {$level}, Blinds: {$this->small_blind}/{$this->big_blind}";
    }

	/**
	 * @todo - Fix or move this function
	 * 
	 * @param integer $level
	 * @returns SingleBlind
	 */
	public static function GetBlind($level) {
		if ($level < 1) {
			throw new Exception("$level must be greated than 0");
		}
		return get_blind($level);
	}
	
	/**
	 * Compares two SingleBlinds by each small_blind variable
	 * 
	 * @param SingleBlind $blind_a
	 * @param SingleBlind $blind_b 
	 */
	public static function CompareBlinds(SingleBlind $blind_a, SingleBlind $blind_b) {
		if ($blind_a->small_blind == $blind_b->small_blind) {
			return 0;
		}

		return $blind_a->small_blind > $blind_b->small_blind ? 1 : -1;
	}
}

?>